<template>
	<view class="">
	<u-navbar title-size="36" height="42" :border-bottom="false" title="线索填报"></u-navbar>
	<view class="new-page">
		<image src="../../static/images/j-wrapper.png" mode="widthFix" class="bg"></image>
		<view class="page-main">
			<view class="form-row flex-center">
				<view class="form-label">姓名</view>
				<view class="flex_bd">
					<input type="text" value="" placeholder="请输入购机人姓名" class="ui-input" placeholder-style="color:#BFBFBF;"/>
				</view>
			</view>
			<view class="form-row flex-center">
				<view class="form-label">电话</view>
				<view class="flex_bd">
					<input type="digit" maxlength="11" value="" placeholder="请输入购机人联系方式" class="ui-input" placeholder-style="color:#BFBFBF;"/>
				</view>
			</view>
			<view class="form-row form-ht-row ">
				<view class="form-label">请选择采购机型及数量</view>
				<view class="flex_bd">
					<view class="dev-row flex-center">
						<view class="flex_bd">
							<view class="dev-select" @click="cateShow = true">
								<view class="flex_bd">
									<input disabled  type="text" value="ZE60E-10" placeholder="请选择设备"  class="ui-input" placeholder-style="color:#BFBFBF;"/>
								</view>
								<image src="../../static/images/dw.png" class="dicon" mode=""></image>
							</view>
							<view class="dev-numbox">
								<input type="number" value="2" placeholder="数量" class="ui-input"  placeholder-style="color:#BFBFBF;"/>
								<view class="t">台</view>
							</view>
						</view>
					</view>
					<view class="dev-row flex-center" v-for="(item,index) in list" :key="index">
						<view class="flex_bd">
							<view class="dev-select" @click="cateShow = true">
								<view class="flex_bd">
									<input disabled  type="text" v-model="item.name"  value="" placeholder="请选择设备" class="ui-input"  placeholder-style="color:#BFBFBF;"/>
								</view>
								<image src="../../static/images/dw.png" class="dicon" mode=""></image>
							</view>
							<view class="dev-numbox">
								<input type="number" v-model="item.number" value="" placeholder="数量" class="ui-input"  placeholder-style="color:#BFBFBF;"/>
								<view class="t">台</view>
							</view>
						</view>
						<image src="../../static/images/de.png" class="del-icon" mode="" @click="list.splice(index,1)"></image>
					</view>
					<view class="dev-link" @click="add">+ 新增采购</view>
				</view>
			</view>
			<view class="form-row flex-center" @click="regionClick()">
				<view class="form-label">请选择省市区</view>
				<view class="flex_bd">
					<view class="region">{{region}}</view>
				</view>
				<image src="../../static/images/dw.png" class="dicon" mode=""></image>
			</view>
			<view class="form-row">
				<textarea value="" @input = "descInput" v-model="desc" placeholder="我还有其他要求…" class="textarea" />
				<view class="num-bar">{{remnant}}/200</view>
			</view>
		</view>
		<view class="btn-foot">
			<button type="default" class="btn btn-submit">提交</button>
		</view>
		<u-picker v-model="show" mode="region" @confirm="confirm"></u-picker>
		<u-picker @columnchange="columnchange" mode="multiSelector" v-model="cateShow" :range="multiSelector" :defaultSelector="defaultSelector"></u-picker>
	</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				cateShow:false,
				multiSelector: [['起重机', '混凝土机械'], ['泵车', '湿喷机'], ['ZE60E-10', 'ZE60E-10', 'ZE60E-10']],
				defaultSelector: [0,0,0],
				show:false,
				region:'',
				remnant:'0',
				desc:'',
				list:[],
				set:[{
					id:'',
					name:'',
					number:''
				}]
			}
		},
		onLoad() {

		},
		methods: {
			regionClick(){
				this.show = true
			},
			confirm(e){
				console.log(e)
				this.region = e.province.label +'-'+ e.city.label +'-'+ e.area.label
			},
			descInput(e){
				this.remnant = e.detail.value.length
			},
			columnchange(e) {
				let column = e.column, index = e.index;
				this.defaultSelector[column] = index;
				switch (column) {
					case 0: 
						switch (index) {
							case 0:
								this.multiSelector[1] = ['泵车', '湿喷机']
								this.multiSelector[2] = ['ZE60E-10', 'ZE60E-10', 'ZE60E-10']
								break
							case 1:
								this.multiSelector[1] = ['泵车2', '湿喷机2']
								this.multiSelector[2] = ['AE60E-10', 'AE60E-10', 'AE60E-10']
								break
						}
						this.defaultSelector.splice(1, 1, 0)
						this.defaultSelector.splice(2, 1, 0)
						break
					case 1: //拖动第2列
						switch (this.defaultSelector[0]) { //判断第一列是什么
							case 0:
								switch (this.defaultSelector[1]) {
									case 0:
										this.multiSelector[2] = ['北京', '上海', '广州']
										break
									case 1:
										this.multiSelector[2] = ['东京','北海道']
										break
								}
								break
							case 1:
								switch (this.defaultSelector[1]) {
									case 0:
										this.multiSelector[2] = ['伦敦', '曼彻斯特']
										break
									case 1:
										this.multiSelector[2] = ['巴黎', '马赛']
										break
								}
								break
						}
						this.defaultSelector.splice(2, 1, 0)
						break
				}
			},
			openUrl(e) {
				console.log(e)
				uni.navigateTo({
					url:e
				});
			},
			add(){
				var res = this.set;
				this.list.push(res[0])
			},
			del(){
				
			}
		}
	}
</script>

<style lang="scss">
	.dev-row{
		margin-bottom: 16rpx;
		> .flex_bd{
			display: flex;
			align-items: center;
		}
		.dev-select{
			width: 334rpx;
			display: flex;
			align-items: center;
			padding: 0 20rpx;
			height: 80rpx;
			background: #FFFFFF;
			border: 1px solid #DDDDDD;
		}
		.dev-numbox{
			margin-left: 20rpx;
			display: flex;
			align-items: center;
			input{
				padding: 0 16rpx;
				width: 94rpx;
				height: 80rpx;
				background: #FFFFFF;
				border: 1px solid #DDDDDD;
			}
			.t{
				margin-left: 10rpx;
			}
		}
		.del-icon{
			width: 30rpx;
			height: 30rpx;
		}
		input{
			font-size: 28rpx;
		}
	}
	.dev-link{
		font-size: 28rpx;
		color: #FE6714;
	}
	.form-ht-row{
		.form-label{
			margin-bottom:30rpx;
		}
	}
	.num-bar{
		text-align: right;
		color: #BFBFBF;
	}
	.form-row{
		.dicon{
			width: 28rpx;
			height: 28rpx;
		}
	}
	.new-page{
		position: relative;
		padding-top: 150rpx;
		padding-left: 30rpx;
		padding-right: 30rpx;
		.bg{
			position: absolute;
			top: 0;
			left: 0;
			width: 100%;
		}
	}
	.page-main{
		position: relative;
		z-index: 99;
		background-color: #FFFFFF;
		padding: 30rpx;
		border-radius: 20rpx;
	}
	.form-row{
		background: #F3F4F6;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 30rpx;
		.form-label{
			margin-right: 32rpx;
		}
		.textarea{
			height: 130rpx;
			font-size: 28rpx;
			width: 100%;
		}
		
		.ui-input{
			font-size: 28rpx;
		}
	}
	.btn-foot{
		padding-bottom: 40rpx;
	}
</style>
